<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Io Tutorial</title>
<META HTTP-EQUIV="EXPIRES" CONTENT=0>
<link rel="stylesheet" href="docs.css">
</head>
<body>

<h1>Io Tutorial</h1>
<p>
<br>

<!--
<center>
	<table style="width:100%">
	<tr>
	<td valign=top style="width:33%">
		<ul>
<div class=indexSection><a href="#Introduction">Introduction</a></div>
<div class=indexItem><a href="#Introduction-Math">Math</a></div>
<div class=indexItem><a href="#Introduction-Variables">Variables</a></div>
<div class=indexItem><a href="#Introduction-Conditions">Conditions</a></div>
<div class=indexItem><a href="#Introduction-Lists">Lists</a></div>
<div class=indexItem><a href="#Introduction-Loops">Loops</a></div>
<div class=indexItem><a href="#Introduction-Strings">Strings</a></div>
<div class=indexItem><a href="#Introduction-Further-Reading">Further Reading</a></div>
</ul>
</td>
</tr>
</table>
</center>

-->

<table cellpadding=0 cellspacing=0 border=0 style="width:35em; border-style:solid; border-width:0px; border-color:#000; padding-right:120px;">

<!--
	<tr>
				<td width=1% align=right>
					<h2>Introduction<a name="Introduction"></a></h2>
				</td>
				<td>
					&nbsp;&nbsp;&nbsp;&nbsp;
				</td>
				<td>


	<div class=indent>

	</tr><tr><td colspan=3 class=sectionDivider></td></tr>
	<tr><td align=right><a name="Introduction-Overview"></a><h3>Overview</h3>
	</td><td></td><td>
		

This is a quick overview of Io intended for folks that already know how to program.<p>
After compiling Io, run the io executable in the binaries folder. You should get a prompt like this:
<pre>
Io 20080120
Io>
</pre>
The following is an annotated transcript of a CLI session that will walk through some examples:
<p>

-->	

	<tr><td colspan=3 class=sectionDivider></td></tr>
	<tr><td align=right><a name="Introduction-Math"></a><h3>Math</h3>
	</td><td></td><td>
		

<pre>
Io> 1+1
==> 2

Io> 2 sin
==> 0.909297

Io> 2 sqrt
==> 1.414214
</PRE>

</tr><tr><td colspan=3 class=sectionDivider></td></tr>
<tr><td align=right><a name="Introduction-Variables"></a><h3>Variables</h3>
</td><td></td><td>
	

<PRE>
Io> a := 1
==> 1

Io> a
==> 1

Io> b := 2 * 3
==> 6

Io> a + b
==> 7
</PRE>

</tr><tr><td colspan=3 class=sectionDivider></td></tr>
<tr><td align=right><a name="Introduction-Conditions"></a><h3>Conditions</h3>
</td><td></td><td>
	
<PRE>
Io> a := 2

Io> if(a == 1) then(writeln("a is one")) else(writeln("a is not one"))
a is not one

Io> if(a == 1, writeln("a is one"), writeln("a is not one"))
a is not one
</PRE>


</tr><tr><td colspan=3 class=sectionDivider></td></tr>
<tr><td align=right><a name="Introduction-Lists"></a><h3>Lists</h3>
</td><td></td><td>
	
<PRE>
Io> d := List clone append(30, 10, 5, 20)    
==> list(30, 10, 5, 20)   

Io> d size
==> 4

Io> d print
==> list(30, 10, 5, 20)

Io> d := d sort
==> list(5, 10, 20, 30)

Io> d first
==> 5

Io> d last
==> 30

Io> d at(2)
==> 20

Io> d remove(30)
==> list(5, 10, 20)

Io> d atPut(1, 123)
==> list(5, 123, 20)

Io> list(30, 10, 5, 20) select(>10)
==> list(30, 20)

Io> list(30, 10, 5, 20) detect(>10)
==> 30

Io> list(30, 10, 5, 20) map(*2)
==> list(60, 20, 10, 40)

Io> list(30, 10, 5, 20) map(v, v*2)
==> list(60, 20, 10, 40)
</PRE>

</tr><tr><td colspan=3 class=sectionDivider></td></tr>
<tr><td align=right><a name="Introduction-Loops"></a><h3>Loops</h3>
</td><td></td><td>
	
<PRE>
Io> for(i, 1, 10, write(i, " "))
1 2 3 4 5 6 7 8 9 10 

Io> d foreach(i, v, writeln(i, ": ", v))
0: 5
1: 123
2: 20

Io> list("abc", "def", "ghi") foreach(println)
abc
def
ghi
</PRE>


</tr><tr><td colspan=3 class=sectionDivider></td></tr>
<tr><td align=right><a name="Introduction-Strings"></a><h3>Strings</h3>
</td><td></td><td>
	
<PRE>
Io> a := "foo"
==> "foo"

Io> b := "bar"
==> "bar"

Io> c := a .. b
==> "foobar"

Io> c at(0)
==> 102

Io> c at(0) asCharacter
==> "f"

Io> s := "this is a test"
==> "this is a test"

Io> words := s split(" ", "\t") print
"this", "is", "a", "test"

Io> s findSeq("is")
==> 2

Io> s findSeq("test")
==> 10

Io> s exSlice(10)
==> "test"

Io> s exSlice(2, 10)
==> "is is a "

</PRE>
</td>
</tr>

<tr><td align=right><a name="Introduction-Further-Reading"></a><h3>More</h3></td>
<td></td><td>
	
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=http://www.quag.geek.nz/io/getting-started/>Quag's Getting Started Tutorial</a>

</td>
</tr>
</table>

<br>
<br>
<br>
<br>
<br>
<br>
